// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nothuman14
//@version=5

indicator('MM | Premium Money Flow [3.2.1]', overlay=false, precision=4, timeframe="", timeframe_gaps=true)




rescale(_src, _oldMin, _oldMax, _newMin, _newMax) =>
    // Rescales series with known min/max.
    // _src            : series to rescale.
    // _oldMin, _oldMax: min/max values of series to rescale.
    // _newMin, _newMin: min/max values of rescaled series.
    _newMin + (_newMax - _newMin) * (_src - _oldMin) / math.max(_oldMax - _oldMin, 10e-10)
grad(src)=>
    color out = switch int(src)
        0 => color.new(#1500FF , 60)
        1 => color.new(#1709F6 , 60)
        2 => color.new(#1912ED , 60)
        3 => color.new(#1B1AE5 , 60)
        4 => color.new(#1D23DC , 60)
        5 => color.new(#1F2CD3 , 60)
        6 => color.new(#2135CA , 60)
        7 => color.new(#233EC1 , 60)
        8 => color.new(#2446B9 , 60)
        9 => color.new(#264FB0 , 60)
        10 => color.new(#2858A7 , 60)
        11 => color.new(#2A619E , 60)
        12 => color.new(#2C6A95 , 60)
        13 => color.new(#2E728D , 60)
        14 => color.new(#307B84 , 60)
        15 => color.new(#32847B , 60)
        16 => color.new(#348D72 , 60)
        17 => color.new(#36956A , 60)
        18 => color.new(#389E61 , 60)
        19 => color.new(#3AA758 , 60)
        20 => color.new(#3CB04F , 60)
        21 => color.new(#3EB946 , 60)
        22 => color.new(#3FC13E , 60)
        23 => color.new(#41CA35 , 60)
        24 => color.new(#43D32C , 60)
        25 => color.new(#45DC23 , 60)
        26 => color.new(#47E51A , 60)
        27 => color.new(#49ED12 , 60)
        28 => color.new(#4BF609 , 60)
        29 => color.new(#4DFF00 , 60)
        30 => color.new(#53FF00 , 60)
        31 => color.new(#59FF00 , 60)
        32 => color.new(#5FFE00 , 60)
        33 => color.new(#65FE00 , 60)
        34 => color.new(#6BFE00 , 60)
        35 => color.new(#71FE00 , 60)
        36 => color.new(#77FD00 , 60)
        37 => color.new(#7DFD00 , 60)
        38 => color.new(#82FD00 , 60)
        39 => color.new(#88FD00 , 60)
        40 => color.new(#8EFC00 , 60)
        41 => color.new(#94FC00 , 60)
        42 => color.new(#9AFC00 , 60)
        43 => color.new(#A0FB00 , 60)
        44 => color.new(#A6FB00 , 60)
        45 => color.new(#ACFB00 , 60)
        46 => color.new(#B2FB00 , 60)
        47 => color.new(#B8FA00 , 60)
        48 => color.new(#BEFA00 , 60)
        49 => color.new(#C4FA00 , 60)
        50 => color.new(#CAF900 , 60)
        51 => color.new(#D0F900 , 60)
        52 => color.new(#D5F900 , 60)
        53 => color.new(#DBF900 , 60)
        54 => color.new(#E1F800 , 60)
        55 => color.new(#E7F800 , 60)
        56 => color.new(#EDF800 , 60)
        57 => color.new(#F3F800 , 60)
        58 => color.new(#F9F700 , 60)
        59 => color.new(#FFF700 , 60)
        60 => color.new(#FFEE00 , 60)
        61 => color.new(#FFE600 , 60)
        62 => color.new(#FFDE00 , 60)
        63 => color.new(#FFD500 , 60)
        64 => color.new(#FFCD00 , 60)
        65 => color.new(#FFC500 , 60)
        66 => color.new(#FFBD00 , 60)
        67 => color.new(#FFB500 , 60)
        68 => color.new(#FFAC00 , 60)
        69 => color.new(#FFA400 , 60)
        70 => color.new(#FF9C00 , 60)
        71 => color.new(#FF9400 , 60)
        72 => color.new(#FF8C00 , 60)
        73 => color.new(#FF8300 , 60)
        74 => color.new(#FF7B00 , 60)
        75 => color.new(#FF7300 , 60)
        76 => color.new(#FF6B00 , 60)
        77 => color.new(#FF6200 , 60)
        78 => color.new(#FF5A00 , 60)
        79 => color.new(#FF5200 , 60)
        80 => color.new(#FF4A00 , 60)
        81 => color.new(#FF4200 , 60)
        82 => color.new(#FF3900 , 60)
        83 => color.new(#FF3100 , 60)
        84 => color.new(#FF2900 , 60)
        85 => color.new(#FF2100 , 60)
        86 => color.new(#FF1900 , 60)
        87 => color.new(#FF1000 , 60)
        88 => color.new(#FF0800 , 60)
        89 => color.new(#FF0000 , 60)
        90 => color.new(#F60000 , 60)
        91 => color.new(#DF0505 , 60)
        92 => color.new(#C90909 , 60)
        93 => color.new(#B20E0E , 60)
        94 => color.new(#9B1313 , 60)
        95 => color.new(#851717 , 60)
        96 => color.new(#6E1C1C , 60)
        97 => color.new(#572121 , 60)
        98 => color.new(#412525 , 60)
        99 => color.new(#2A2A2A , 60)
        100 => color.new(#220027 , 60)
    out

filter(float src, int len) =>
    var float filter = na
    filter := ta.cum((src + (src[1] * 2) + (src[2] * 2) + src[3])/6)
    (filter - filter[len])/len

rsi(src, len) =>
    rsi = ta.rsi(filter(src, 1), len)
    f = -math.pow(math.abs(math.abs(rsi - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50
    rsia = if rsi > 50
        f + 50
    else
        -f + 50
    rsia
length2 = 8
rsi = rsi(close, length2)

//barcolor(grad(rsi))


Istyle = input.string("Area",title = "Style",options = ["Area","Histogram"] , group = "Basic - Settings")

bayesPeriod = input(20, title='Trend Lookback Period' , group = "Basic - Settings")

ShowPump     = input(true, title='Pump Detector', group = "Pump & Dump - Settings" , inline = "PND")
ShowDump     = input(true, title='Dump Detector' , group = "Pump & Dump - Settings" , inline = "PND")
bbSmaPeriod  = input(20, title='Trend Agility', group = "Pump & Dump - Settings")
bbStdDevMult = input.float(2.5, title='Pump & Dump Sensitivity', maxval=50.0, group = "Pump & Dump - Settings")
smaPeriod    = input(11, title='Pump & Dump Average' , group = "Pump & Dump - Settings")

Showbankers = input(true, title='Show Bankers', group = "Pump & Dump - Settings" , inline = "PND")
bankerthreshold = input.int(3, title='Bankers Entry Threshold', minval=1 , group = "Bankers Entry - Settings")

ShowMF = input(true, title='Show Magic Flakes |', group = "Magic Flakes - Settings",  inline = "MF")
lengthTy = input(50, title='Magic Flakes Length', group = "Magic Flakes - Settings",  inline = "MF")

src = close
showTS = input(title='Show Trend Shifter', defval=false, group = "Trend Shifter - Settings", inline = "TSR")
showsignals = input(title='Trend Shifts', defval=false, group = "Trend Shifter - Settings", inline = "TSR")
length = input.int(50, 'Length', minval=1, group = "Trend Shifter - Settings", inline = "TSRS")
SSF = input.int(30, 'Smoothing', minval=1, group = "Trend Shifter - Settings", inline = "TSRS")

iNVESTORS = input(false, title="Show Investor's", group = "Investor - Settings" , inline = "NOPE" , tooltip = "Must use on D Timeframe or bigger for better result")

h1h = input.int(title='Money Flow | Min', defval=3, minval=1, maxval=99 , group = "Investor - Settings" , inline = "Investor")
l1h = input.int(title='Max', defval=9, minval=1, maxval=99 , group = "Investor - Settings" , inline = "Investor")

TrendValidator = input(true, title="Show Trend Validator",group = "Trend Validator - Settings" )
par1 = input.int(20, title='Fast Length', minval=1 , group = "Trend Validator - Settings" , inline = "TV")
par2 = input.int(200, title='Slow Length', minval=2, group = "Trend Validator - Settings" , inline = "TV")
filter = false
//filter = input(false, title='ATR filter')


StyleVal = plot.style_histogram

//functions

if Istyle == "Histogram"
    StyleVal := plot.style_histogram

if Istyle == "Area"
    StyleVal := plot.style_area

xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values[i])
                r_val := values[i]
                r_val
    r_val
xsa(src, len, wei) =>
    sumf = 0.0
    ma = 0.0
    out = 0.0
    sumf := nz(sumf[1]) - nz(src[len]) + src
    ma := na(src[len]) ? na : sumf / len
    out := na(out[1]) ? ma : (src * wei + out[1] * (len - wei)) / len
    out


//model of banker model with customized input threshold

bankermodel = 3 * xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1) - 2 * xsa(xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1), 3, 1)
crossover_1 = ta.crossover(bankermodel, bankerthreshold)
pumpdumpsoon = crossover_1 ? 100 : 0
longshortentry = bankermodel <= 3 ? 50 : 0
bankermove = bankermodel < 5 ? 25 : 0



// Magic Flakes

//Credit to LazyBearTy for some of his CVI code\\

ValC = ta.sma(hl2, lengthTy)

bullTy = -1.0
bearTy = 1.0
volTy = ta.sma(ta.atr(lengthTy), lengthTy)
//filter=sma(cvi, 400)
// os2=input(-1.5, title="Oversold 2")
// ob2=input(1.5, title="Overbought 2")


cvi = (close - ValC) / (volTy * math.sqrt(lengthTy))

//plot(bullTy, color=green)
//plot(bearTy, color=red)

// plot(os2, color=green, style=3)
// plot(ob2, color=red, style=3)
cb = cvi <= bullTy ? #00DBFF : cvi >= bearTy ? #E91E63  : cvi > bullTy ? color.blue : cvi < bearTy ? color.blue : na
bullTy1 = cvi <= bullTy
bearTy1 = cvi >= bearTy
bullTy2 = bullTy1[1] and not bullTy1
bearTy2 = bearTy1[1] and not bearTy1
plotshape(bullTy2, style=shape.diamond, location=location.top, color=color.new(#00DBFF, 50), size=size.small)
plotshape(bearTy2, style=shape.diamond, location=location.top, color=color.new(#E91E63 , 50), size=size.small)
//plotchar(bearTy1 ? cb : na)
//plot(cvi, color=cb, style=histogram, linewidth=2)
//plot(filter, color=red, linewidth=2)



bbBasis = ta.sma(close, bbSmaPeriod)
bbStdDev = bbStdDevMult * ta.stdev(close, bbSmaPeriod)

bbUpper = bbBasis + bbStdDev
bbLower = bbBasis - bbStdDev
// Bayesian Theorem Starts
// AO
aoFast = 5
aoSlow = 34
ao = ta.sma(hl2, aoFast) - ta.sma(hl2, aoSlow)
colorAo = ta.change(ao) > 0 ? #00DBFF : #E91E63

// AC
acFast = 5
acSlow = 34
xSMA1_hl2 = ta.sma(hl2, acFast)
xSMA2_hl2 = ta.sma(hl2, acSlow)
xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2
xSMA_hl2 = ta.sma(xSMA1_SMA2, acFast)
ac = xSMA1_SMA2 - xSMA_hl2
cClr = ac > ac[1] ? color.blue : #E91E63

acAo = (ac + ao) / 2

maAcAoPeriod = 13
showMaAcAo = false
maAcAo = ta.vwma(acAo, maAcAoPeriod)

// Combine AC & AO
acIsBlue = ac > ac[1]
acIsRed = not(ac > ac[1])
aoIsGreen = ta.change(ao) > 0
aoIsRed = not(ta.change(ao) > 0)
acAoIsBullish = acIsBlue and aoIsGreen
acAoIsBearish = acIsRed and acIsRed
acAoColorIndex = acAoIsBullish ? 1 : acAoIsBearish ? -1 : 0

// Alligator
smma(src, length) =>
    smma = 0.0
    smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length
    smma
lipsLength = 5
teethLength = 8
jawLength = 13
lipsOffset = 3
teethOffset = 5
jawOffset = 8
lips = smma(hl2, lipsLength)
teeth = smma(hl2, teethLength)
jaw = smma(hl2, jawLength)

// SMA

smaValues = ta.sma(close, smaPeriod)



// Next candles are breaking Down
probBbUpperUpSeq = close > bbUpper ? 1 : 0
probBbUpperUp = math.sum(probBbUpperUpSeq, bayesPeriod) / bayesPeriod
probBbUpperDownSeq = close < bbUpper ? 1 : 0
probBbUpperDown = math.sum(probBbUpperDownSeq, bayesPeriod) / bayesPeriod

probUpBbUpper = probBbUpperUp / (probBbUpperUp + probBbUpperDown)

probBbBasisUpSeq = close > bbBasis ? 1 : 0
probBbBasisUp = math.sum(probBbBasisUpSeq, bayesPeriod) / bayesPeriod
probBbBasisDownSeq = close < bbBasis ? 1 : 0
probBbBasisDown = math.sum(probBbBasisDownSeq, bayesPeriod) / bayesPeriod

probUpBbBasis = probBbBasisUp / (probBbBasisUp + probBbBasisDown)

probSmaUpSeq = close > smaValues ? 1 : 0
probSmaUp = math.sum(probSmaUpSeq, bayesPeriod) / bayesPeriod
probSmaDownSeq = close < smaValues ? 1 : 0
probSmaDown = math.sum(probSmaDownSeq, bayesPeriod) / bayesPeriod

probUpSma = probSmaUp / (probSmaUp + probSmaDown)

sigmaProbsDown = nz(probUpBbUpper * probUpBbBasis * probUpSma / probUpBbUpper * probUpBbBasis * probUpSma + (1 - probUpBbUpper) * (1 - probUpBbBasis) * (1 - probUpSma))

// Next candles are breaking Up
probDownBbUpper = probBbUpperDown / (probBbUpperDown + probBbUpperUp)
probDownBbBasis = probBbBasisDown / (probBbBasisDown + probBbBasisUp)
probDownSma = probSmaDown / (probSmaDown + probSmaUp)

sigmaProbsUp = nz(probDownBbUpper * probDownBbBasis * probDownSma / probDownBbUpper * probDownBbBasis * probDownSma + (1 - probDownBbUpper) * (1 - probDownBbBasis) * (1 - probDownSma))


fatr(length) =>
    a1 = ta.atr(1)
    a200 = ta.atr(200)
    tol = a200 + 3 * ta.stdev(a1, 200)  // assume that events larger than 3 sigma are exceptional
    fa = a1 > tol ? a200 : a1  // and filters them out
    ta.sma(fa, length)

fatr__1 = fatr(par1)
atr_1 = ta.atr(par1)
sig1 = filter ? fatr__1 : atr_1
fatr__2 = fatr(par2)
atr_2 = ta.atr(par2)
sig2 = filter ? fatr__2 : atr_2

sig = 100 * (sig1 - sig2) / sig2
//lvl = sma(abs(sig),par2) // old definition of vol thr
lvl = ta.stdev(sig, par2)

col = sig <= 0 ? #E91E63 : #00DBFF
//pp = plot(sig, linewidth=3, color=col, title='volatility')
//pm = plot(-sig, linewidth=3, color=col, title='volatility mirror')
//plot(lvl, color=color.new(color.aqua, 0), title='extreme volatility threshold')
//plot(-lvl, color=color.new(color.aqua, 0), title='extreme volatility threshold mirror')


//background
//bgcolor(magikc)
//functions
Level0 = 0



xrf22(values, len22gth22) =>
    r_val2 = float(na)
    if len22gth22 >= 1
        for i = 0 to len22gth22 by 1
            if na(r_val2) or not na(values[i])
                r_val2 := values[i]
                r_val2
    r_val2
xsa22(src22, len22, wei22) =>
    sumf22 = 0.0
    ma = 0.0
    out = 0.0
    sumf22 := nz(sumf22[1]) - nz(src22[len22]) + src22
    ma := na(src22[len22]) ? na : sumf22 / len22
    out := na(out[1]) ? ma : (src22 * wei22 + out[1] * (len22 - wei22)) / len22
    out
    
//algorithm
var2 = xrf22(low, l1h)
var3 = xsa22(math.abs(low - var2), h1h, 1) / xsa22(math.max(low - var2, 0), h1h, 1) * 100
var4 = ta.ema(close * 1.2 ? var3 * h1h : var3 / h1h, h1h)
var5 = ta.lowest(low, 34)
var6 = ta.highest(var4, 34)
lowest_1 = ta.lowest(low, 55)
var7 = lowest_1 ? 1 : 0
var8 = ta.ema(low <= var5 ? (var4 + var6 * 2) / 2 : 0, 3) / 618 * var7
var9 = ta.ema(close, 5)
var10 = (close - ta.sma(close, 34)) / ta.sma(close, 34) * -10
var11 = ta.ema(low <= var5 ? (var4 + var6 * 2) / 2 : 0, 3) / 618 * var7 * -1
var12 = ta.ema(close, 5) * -1

//plot sudden dump strength with yellow stick lines
//plotcandle(0,var8, 0, var8, color=var8>xrf22(var8,1)?color.yellow:na )
xl1 = ta.sma(low, 2) * 0.96
xl2 = ta.sma(low, 26) * 0.85
xl3 = xrf22(xl1, 1) < xl2 and xrf22(xl1, 1) < xl1 and xrf22(xl1, 1) < xrf22(xl1, 2)
dump = xl3 ? 0 : var8 * 1

//after a dump there are some quick chance to see a temporary bottom in lime sticks
//plotcandle(0,-var11, 0, -var11, color=var11>xrf22(var11,1)?color.lime:na )
// plot orange curve to track post-dump opportunity
xrf22_1 = xrf22(var8, 1)
fundready = var8 > xrf22_1 ? 0 : var8


//use KDJ to detect long entry opportunity after a dump
rsv = (close - ta.lowest(low, 9)) / (ta.highest(high, 9) - ta.lowest(low, 9)) * 100
k = xsa22(rsv, 3, 1)
d = xsa22(k, 3, 1)
j = 3 * k - 2 * d
x = ta.lowest(j, 2) == ta.lowest(j, 8)
longengry = ta.crossover(j, xrf22(j + 0.01, 1)) and fundready > 0 and dump > 0
//bgcolor( longengry ? color.green:na, transp=40)

RSII = ta.ema(ta.rsi(src, length), SSF)

TR = math.abs(RSII - RSII[1])

wwalpha = 1 / length

WWMA = 0.0

WWMA := wwalpha * TR + (1 - wwalpha) * nz(WWMA[1])

ATRRSI = 0.0

ATRRSI := wwalpha * WWMA + (1 - wwalpha) * nz(ATRRSI[1])

TsFast = ta.ema(ta.rsi(src, length), SSF)

TsUP = TsFast + ATRRSI * 4.236
TsDN = TsFast - ATRRSI * 4.236

TsSlow = 0.0

TsSlow := TsUP < nz(TsSlow[1]) ? TsUP : TsFast > nz(TsSlow[1]) and TsFast[1] < nz(TsSlow[1]) ? TsDN : TsDN > nz(TsSlow[1]) ? TsDN : TsFast < nz(TsSlow[1]) and TsFast[1] > nz(TsSlow[1]) ? TsUP : nz(TsSlow[1])

Colorh = TsFast > 60 ? color.rgb(255, 0, 0) : TsFast < 40 ? color.rgb(0, 255, 8) : grad(rsi)

QQF = plot(TsFast, 'TS FAST', color=color.new(color.maroon, 100), linewidth=2, display=display.none, editable = false)
QQS = plot(TsSlow, 'TS SLOW', color=color.new(color.white, 100), linewidth=2, display=display.none , editable = false)

plot(showTS ? TsFast : na,color  = color.new(Colorh , 0), linewidth=1, style=StyleVal, histbase=50 , editable = false)


BearLimit = hline(showTS ? 60 : na, color=color.gray, linestyle=hline.style_dashed)
BullLimt = hline(showTS ?40: na, color=color.gray, linestyle=hline.style_dashed)

bulllim = 40
bearlim = 60
BullSignalr = ta.crossover(TsFast, TsSlow) and TsFast < bulllim
BearSignallr = ta.crossunder(TsFast, TsSlow) and TsFast > bearlim


//alertcondition(ta.cross(TsFast, TsSlow), title='Cross Alert', message='TrendShifter Crossing Signal!')
//alertcondition(ta.crossover(TsFast, TsSlow), title='Crossover Alarm', message='TrendShifter Bull SIGNAL!')
//alertcondition(ta.crossunder(TsFast, TsSlow), title='Crossunder Alarm', message='TrendShifter Bear SIGNAL!')
//alertcondition(ta.crossover(TsFast, 50), title='Cross 0 Up Alert', message='TrendShifter FAST Crossing 0 UP!')
//alertcondition(ta.crossunder(TsFast, 50), title='Cross 0 Down Alert', message='TrendShifter FAST Crossing 0 DOWN!')
//alertcondition(ta.crossover(TsFast, 60), title='Cross 10 Up Alert', message='TrendShifter Above 10 UPTREND SIGNAL!')
//alertcondition(ta.crossunder(TsFast, 40), title='Cross -10 Down Alert', message='TrendShifter Below -10 DOWNTREND SIGNAL!')
//alertcondition(ta.crossunder(TsFast, 60) or ta.crossover(TsFast, 40), title='SIDEWAYS', message='TrendShifter Entering Sideways Market!')


//hline(Level0 , linestyle = hline.style_solid, title='Level - 0', color=color.lime, linewidth=1)


plot(ShowDump ? sigmaProbsDown * 100 : na, title='Dump Detector', color=color.new(#E91E63, 50), linewidth=2 , style=StyleVal)
plot(ShowPump ? sigmaProbsUp * 100 : na, title='Pump Detector', color=color.new(#00DBFF, 50), linewidth=2 , style=StyleVal)
probPrime = nz(sigmaProbsDown * sigmaProbsUp / sigmaProbsDown * sigmaProbsUp + (1 - sigmaProbsDown) * (1 - sigmaProbsUp))
//model banker move
pbankermove = plot(Showbankers ? bankermove : na, title = "Bankers Thinking", color=color.new(#3bff5c, 70), linewidth=3, style=StyleVal)
//model long short entry
plongshortentry = plot(Showbankers ? longshortentry : na, title = "Bankers Prepairing", color=color.new(#33ff00, 30), linewidth=3, style=StyleVal)
//model banker pump or dump start soon
ppumpdumpsoon = plot(Showbankers ? pumpdumpsoon : na, title = "Bankers Entring" , color=color.new(#00DBFF, 30), linewidth=4, style=StyleVal)

plot(iNVESTORS ? dump :na, title = "Investing Time has come",color=color.new(#00DBFF, 0), style=StyleVal)

plot(iNVESTORS ? fundready : na, color=color.new(#33ff00, 0),title = "Investors are Buying",style=StyleVal)

//plot(sig2,color=white)
hhh = hline(TrendValidator ? 100: na, color=#00DBFF , linestyle = hline.style_solid , linewidth = 2, title='Valid Level')
lll = hline(TrendValidator ? 0 : na, color=#E91E63 , linestyle = hline.style_solid , linewidth = 3, title='Base Level')

magikc = sig <= 0 ? color.new(#ff009d, 90) : color.new(#1ee2e9, 90)
//fill(pp, pm, color=col, transp=90)
fill(hhh, lll, color=magikc, transp=90)

//plotshape(BullSignalr and showsignals ? TsSlow * 0.995 : na, title='Trend Shift - Bullish', text='Bull', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 10), textcolor=color.new(#ffffff, 0))
//plotshape(BearSignallr and showsignals ? TsSlow * 1.005 : na, title='Trend Shift - Bearish', text='Bear', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 10), textcolor=color.new(#ffffff, 0))
plotshape(BullSignalr and showsignals ? TsSlow * 0.995 : na, title='Trend Shift - Bullish', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(#00ff08, 0))
plotshape(BullSignalr and showsignals ? TsSlow * 0.995 : na, title='Trend Shift - Bullish', location=location.absolute, style=shape.circle, size=size.small, color=color.new(#09ff11, 50))

plotshape(BearSignallr and showsignals ? TsSlow * 1.005 : na , title='Trend Shift - Bearish', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(#ff0000, 0))
plotshape(BearSignallr and showsignals ? TsSlow * 1.005 : na , title='Trend Shift - Bearish', location=location.absolute, style=shape.circle, size=size.small, color=color.new(#ff0909, 50))


